package com.example.freemarker.template;

import com.example.annotations.Autowired;
import com.example.annotations.Compontent;
import com.example.freemarker.config.DirectiveHandler;
import com.example.freemarker.config.FreemarkerCompontent;
import com.example.freemarker.config.TemplateDirective;
import com.example.model.title.model.ContentModel;
import com.example.model.title.model.TitleModelExt;
import com.example.model.title.service.ContentModelService;
import com.example.model.title.service.TitleModelService;

/**
 * @Classname ContentModelTemplate
 * @Description TODO
 * @Date 2022/8/8 19:26
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@FreemarkerCompontent("contentmodel")
@Compontent
public class ContentModelTemplate extends TemplateDirective {

    @Autowired
    TitleModelService titleModelService;

    @Override
    public String getName() {
        return "contentmodel";
    }

    @Override
    public void execute(DirectiveHandler handler) throws Exception {
        Integer id=handler.getInteger("contentId");
        TitleModelExt titleModelExt=titleModelService.getTitleModelExtById(id);
        handler.put(RESULT,titleModelExt).render();
    }
}
